<!DOCTYPE html>
<html class="ui-page-login">

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="css/mui.min.css" rel="stylesheet" />
		<link href="css/style.css" rel="stylesheet" />
		<style>
			.area {
				margin: 20px auto 0px auto;
			}
			
			.mui-input-group {
				margin-top: 10px;
			}
			
			.mui-input-group:first-child {
				margin-top: 20px;
			}
			
			.mui-input-group label {
				width: 22%;
			}
			
			.mui-input-row label~input,
			.mui-input-row label~select,
			.mui-input-row label~textarea {
				width: 78%;
			}
			
			.mui-checkbox input[type=checkbox],
			.mui-radio input[type=radio] {
				top: 6px;
			}
			
			.mui-content-padded {
				margin-top: 25px;
			}
			
			.mui-btn {
				padding: 10px;
			}
			
			.link-area {
				display: block;
				margin-top: 25px;
				text-align: center;
			}
			
			.spliter {
				color: #bbb;
				padding: 0px 8px;
			}
			
			.oauth-area {
				position: absolute;
				bottom: 20px;
				left: 0px;
				text-align: center;
				width: 100%;
				padding: 0px;
				margin: 0px;
			}
			
			.oauth-area .oauth-btn {
				display: inline-block;
				width: 50px;
				height: 50px;
				background-size: 30px 30px;
				background-position: center center;
				background-repeat: no-repeat;
				margin: 0px 20px;
				border: solid 1px #ddd;
				border-radius: 25px;
			}
			
			.oauth-area .oauth-btn:active {
				border: solid 1px #aaa;
			}
			
			.oauth-area .oauth-btn.disabled {
				background-color: #ddd;
			}
		</style>
		
		<style type="text/css">
			.footer{
				position: absolute;
				bottom: 200px;
				width: 100%;
				height: 20px;
				font-size: 10px;
				color: rgb(169,169,169);
				line-height:20px ;
			}
			#footer-title{
				margin-left: 25px;
			}
			.footer hr{
				display: inline-block;
				width: 120px;
				height: 1px;
				background-color: #000000;
			}
			.footer span{
				margin-left: 10px;
				margin-right: 10px;
				font-size: 10px;
				color: rgb(169,169,169);
			}
			 .login-icon{
    		    margin-top: 40px;
		        display: flex;
		        margin-left: 50px;
			}
		    .login-img{
		        width: 40px;
		        height: 40px;
		        border-radius: 50%;
		        margin-right: 40px;
				margin-left: 20px;
		    }
		    .login-img img{
		        width: 100%;
		        height: 100%;
		    }
			.mui-bar-nav span{
				font-size: 20px;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<span class=" mui-icon mui-icon-closeempty" id="app_quit"></span>
			<h1 class="mui-title">登录</h1>
		</header>
		<div class="mui-content">
			<form id='login-form' class="mui-input-group">
				<div class="mui-input-row">
					<label>账号</label>
					<input id='account' type="text" class="mui-input-clear mui-input" placeholder="请输入账号">
				</div>
				<div class="mui-input-row">
					<label>密码</label>
					<input id='password' type="password" class="mui-input-clear mui-input" placeholder="请输入密码">
				</div>
			</form>
			<div class="mui-content-padded">
				<button id='login' class="mui-btn mui-btn-block mui-btn-primary">登录</button>
				<div class="link-area"><a id="phone-login">手机快捷登录</a><span class="spliter">|</span><a id='reg'>注册账号</a> <span class="spliter">|</span> <a id='forgetPassword'>忘记密码</a>
				</div>
			</div>
			<div class="footer">
				<div id="footer-title">
					<hr><span>第三方登陆</span><hr >
				</div>
				<div id="other-login">
					 <div class="login-icon">
					    <div class="login-img">
					       <img src="./images/weixin.png" alt="" id="weixin">
					     </div>
					  <div class="login-img">
					         <img src="./images/sinaweibo.png" alt="" id="weibo">
					         </div>
					  <div class="login-img">
					          <img src="./images/qq.png" alt="" id="qq">
					      </div>
					  </div>
					   </div>
				</div>
			</div>
		</div>
		<script src="js/mui.min.js"></script>
		<script src="js/mui.enterfocus.js"></script>
		<script src="js/app.js"></script>
		<script>
			document.getElementById('app_quit').onclick=()=>{
				//1.2
				mui.back = function() {
					var btn = ["确定", "取消"];
					mui.confirm('确认关闭当前窗口？', 'Hello MUI', btn, function(e) {
						if(e.index == 0) {
							plus.runtime.quit();
						}
					});
				}

			}
			document.getElementById('reg').onclick=()=>{
				window.location = 'reg.html'
			}
			document.getElementById('forgetPassword').onclick=()=>{
				window.location = 'forget_password.html'
			}
			document.getElementById('weibo').onclick=()=>{
				window.location = 'other_login.html'
			}
			document.getElementById('weixin').onclick=()=>{
				window.location = 'other_login.html'
			}
			document.getElementById('qq').onclick=()=>{
				window.location = 'other_login.html'
			}
			var logbutton = document.getElementById('login');
			logbutton.onclick=()=>{
				var username = document.getElementById('account').value;
				var password = document.getElementById('password').value;
				if(username==null || password ==null)
				mui.alert("账号和密码不能为空！");
				var url = "../onlinechat/interface/login.php"
				mui.ajax(url,{
					data:"username="+username+"&password="+password,
					dataType:'json',
					type:'post',
					timeout:10000,
					success:function(data){
						
						if(data.code==0){
							mui.toast('登陆成功');
							// console.log(data.data['sign_str']);
							localStorage.setItem("my_data",JSON.stringify(data.data));
							localStorage.getItem('my_sign_str');
							// console.log(JSON.parse(localStorage.getItem('my_data')));
							localStorage.setItem('my_head_logo',data.data['head_logo']);
							// console.log(localStorage.getItem('my_head_logo'));
							localStorage.setItem('my_sign_str',data.data['sign_str']);
							localStorage.setItem('my_user_id',data.data['id']);
							localStorage.setItem('my_nickname',data.data['nickname']);
							localStorage.setItem('my_onlinechat_number',data.data['onlinechat_number'])
							window.location = 'main.html';
						}
						else {
							mui.toast(data.msg);
						}
					},
					error:function(xhr,type,errorThrown){
					        //异常处理；
					        console.log(type);
					 }
				});
			}
		</script>
	</body>

</html>